/**
 * Created by Administrator on 2019/3/4.
 */

var CLASSNAME = [];

window.onload = function () {
    var atts = document.getElementsByClassName('att');

    for (var i in atts) {

        CLASSNAME[i] = atts[i].className;
    }
}

function savedata() {
    var atts = document.getElementsByClassName('att');

    for (var i in atts) {

        // atts[i].disabled = 'true';
        // atts[i].readonly = 'true';

        atts[i].className = CLASSNAME[i];
    }
    // 获取修改后的数据
    personalform = document.getElementById('personinfoform');

    fd =new FormData(personinfoform);

    var xhr = new XMLHttpRequest();

    xhr.open('post','/app1/updateInfo/');

    xhr.send(fd);

    xhr.onreadystatechange = function () {
        if (xhr.readyState == 4) {
            if (xhr.status == 200 || xhr.status == 304) {
                // ret = JSON.parse(xhr.responseText)
            }
        }
    }
}

function modify() {
    var atts = document.getElementsByClassName('att');

    for (var i in atts) {

        atts[i].removeAttribute('disabled');
        atts[i].removeAttribute('readonly');

        atts[i].className += ' add-border';
    }


    // var sex1 = document.getElementById('sexnv');
    // var sex2 = document.getElementById('sexnan');
    //
    // sex1.removeAttribute('disabled');
    // sex2.removeAttribute('disabled');
    //
    // var province = document.getElementById('province');
    // province.removeAttribute('disabled');
    //
    // var city = document.getElementById('city')
    // city.removeAttribute('disabled');
}

function shengshi() {
    var province = document.getElementById('province');
    var city = document.getElementById('city');

    var lncity = ['沈阳市', '大连市', '鞍山市'];
    var jlcity = ['长春市', '四平市'];
    var hbcity = ['武汉市', '孝感市', '荆门市'];
    var sxcity = ['西安市', '咸阳市', '汉中市'];

    city.innerHTML = '';

    if (province.value == '辽宁省') {
        for(var i in lncity)
        {
            city.innerHTML += '\<option value="'+ lncity[i] +'"\>'+ lncity[i] +'\</option\>';
        }
    }

    if (province.value == '吉林省') {
        for(var i in jlcity)
        {
            city.innerHTML += '\<option value="'+ jlcity[i] +'"\>'+ jlcity[i] +'\</option\>';
        }
    }

    if (province.value == '湖北省') {
        for(var i in hbcity)
        {
            city.innerHTML += '\<option value="'+ hbcity[i] +'"\>'+ hbcity[i] +'\</option\>';
        }
    }

    if (province.value == '陕西省') {
        for(var i in sxcity)
        {
            city.innerHTML += '\<option value="'+ sxcity[i] +'"\>'+ sxcity[i] +'\</option\>';
        }
    }

}

function upload() {
    var obj = document.getElementById('upload');
    obj.click();   // 执行obj的事件
}

function doupload() {
    var from = document.getElementById('photo');

    var fd = new FormData(from);

    var xhr = new XMLHttpRequest();

    xhr.open('post','/app1/uploadphoto/');

    xhr.send(fd);

    xhr.onreadystatechange = function () {
        if (xhr.readyState == 4) {
            if (xhr.status == 200 || xhr.status == 304) {
                ret = JSON.parse(xhr.responseText)
                obj = document.getElementById('background');
                obj.style.backgroundImage = "url('"+ret.user_photo +"')";
            }
        }
    }
}

function quiz() {
    var obj = document.getElementById('Modal-wrapper');

    obj.style.display = 'block'; //none ---> block
}

function closeWin() {
    var obj = document.getElementById('Modal-wrapper');

    obj.style.display = 'none'; //block  --->  none
}

















